Skip to content

Add LiteRT-LM LoRA adapter support#206

Open
leehack wants to merge 7 commits into
mainfrom
litert-lora-adapters
Open

Add LiteRT-LM LoRA adapter support#206
leehack wants to merge 7 commits into
mainfrom
litert-lora-adapters

Conversation

@leehack

@leehack leehack commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • add native .litertlm LoRA support for one LiteRT-LM adapter at scale 1.0
  • route ModelParams.loras and engine.setLora(...)/removeLora(...)/clearLoras() through the LiteRT-LM service on native targets
  • bind Dart FFI to litert_lm_session_config_set_lora_file, with an explicit unsupported-runtime error when older native bundles do not export the symbol
  • keep multiple weighted adapters on GGUF/llama.cpp and keep LiteRT-LM web rejecting LoRA explicitly
  • update README, website docs, smoke tooling, and ## Unreleased changelogs

Native runtime dependency

This PR requires a litert-lm-native runtime that exports litert_lm_session_config_set_lora_file.

Companion native runtime PR: leehack/litert-lm-native#7

Validation

  • dart analyze lib/src/backends/litert_lm/litert_lm_runtime.dart lib/src/backends/litert_lm/litert_lm_runtime_stub.dart lib/src/backends/litert_lm/litert_lm_service.dart tool/litert_lm_engine_smoke.dart test/unit/backends/litert_lm/litert_lm_runtime_test.dart test/unit/backends/litert_lm/litert_lm_service_test.dart test/unit/backends/litert_lm/litert_lm_backend_test.dart test/unit/backends/litert_lm/worker_test.dart test/unit/backends/native/native_backend_test.dart
  • dart test test/unit/backends/litert_lm/litert_lm_runtime_test.dart test/unit/backends/litert_lm/litert_lm_service_test.dart test/unit/backends/litert_lm/litert_lm_backend_test.dart test/unit/backends/litert_lm/worker_test.dart test/unit/backends/native/native_backend_test.dart
  • dart test test/unit/backends/litert_lm/worker_test.dart
  • ./tool/docs/validate_links.sh
  • git diff --check
  • macOS real runtime smoke with locally built native PR Feature: Configurable Llama.cpp Backend Selection #7 runtime and upstream LiteRT-LM fixtures:
    • base: LLAMADART_LITERT_LM_LIB_DIR=/opt/UnitySrc/personal/llama/litert-lm-native-lora-support/bin/macos/arm64 dart run tool/litert_lm_engine_smoke.dart /private/tmp/litert-lm-v0.13.1-src/runtime/testdata/test_lm.litertlm cpu "What is 2+2? Answer only with the number." 8 256
    • ModelParams.loras: LITERT_LM_LORA=/private/tmp/litert-lm-v0.13.1-src/runtime/testdata/test_lora_rank32_f16_all_ones.tflite dart run tool/litert_lm_engine_smoke.dart ...
    • engine.setLora(...): LITERT_LM_LORA_MODE=set LITERT_LM_LORA=/private/tmp/litert-lm-v0.13.1-src/runtime/testdata/test_lora_rank32_f16_all_ones.tflite dart run tool/litert_lm_engine_smoke.dart ...
    • negative control: an existing non-LoRA file failed at native conversation creation, confirming the adapter path is not silently ignored

Notes

The macOS smoke used upstream real LiteRT-LM model/LoRA fixtures, not a production Gemma LoRA adapter. The tiny fixture produced identical decoded text with and without the adapter, so validation relies on positive load/generation plus the negative invalid-adapter control.

Refs #173

@codecov-commenter

codecov-commenter commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.59%. Comparing base (343574c) to head (3bf3476).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #206   +/-   ##
=======================================
  Coverage   80.59%   80.59%           
=======================================
  Files          85       85           
  Lines       11407    11408    +1     
=======================================
+ Hits         9193     9194    +1     
  Misses       2214     2214           
Flag Coverage Δ
unittests 80.59% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Chat app preview deployed for a81529e.

@leehack leehack marked this pull request as ready for review June 7, 2026 02:38
Copilot AI review requested due to automatic review settings June 7, 2026 02:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request clarifies LiteRT-LM LoRA adapter limitations in both user-facing docs and the LiteRT-LM backend’s runtime/load-time error reporting, specifically tying the failures to the pinned litert-lm-native@v0.13.1 public C ABI lacking LoRA setters.

Changes:

  • Documented that LoRA remains supported via llama.cpp/GGUF backends while native .litertlm rejects ModelParams.loras and runtime LoRA operations due to the pinned v0.13.1 C ABI surface.
  • Updated LiteRT-LM backend error messages to be actionable (include “public C ABI” + pinned version) and reused the same message for runtime LoRA calls.
  • Pinned unit tests to assert the improved LoRA error messaging.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/docs/platforms/support-matrix.md Expands LiteRT-LM limitations to explicitly call out LoRA rejection and the v0.13.1 C ABI reason.
website/docs/guides/lora-adapters.md Adds platform guidance: LoRA works on llama.cpp/GGUF; LiteRT-LM .litertlm currently rejects LoRA due to ABI limitations.
website/docs/changelog/recent-releases.md Adds 0.7.2 highlights describing the clarified LiteRT-LM LoRA diagnostics.
test/unit/backends/litert_lm/litert_lm_service_test.dart Strengthens assertions to require the actionable LoRA error substrings (public C ABI, v0.13.1, backend guidance).
README.md Updates LiteRT-LM limitations section to clarify LoRA support scope and the pinned ABI limitation.
lib/src/backends/litert_lm/litert_lm_service.dart Introduces a shared detailed LoRA unsupported message and appends it to load-time validation errors when loras are provided.
CHANGELOG.md Adds 0.7.2 entry describing improved LiteRT-LM LoRA diagnostics and documentation updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/backends/litert_lm/litert_lm_service.dart Outdated
@leehack leehack changed the title Clarify LiteRT-LM LoRA adapter limitations Add LiteRT-LM LoRA adapter support Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants